<template>
    <div>
        <van-field v-model="password" placeholder="请设置密码"/>
        <van-button class="login_button" :disabled="!flag" round type="danger" size="large" @click="registerFn">注册</van-button>
    </div>
</template>

<script>
import Vue from 'vue'
import { Field, Button } from 'vant'
import { dofinishregister } from '@/api/register'

Vue.use(Field)
Vue.use(Button)
export default {
  computed: {
    flag () {
      return this.password.length > 5
    }
  },
  data () {
    return {
      password: ''
    }
  },
  methods: {
    async registerFn () {
      var res = await dofinishregister({
        tel: localStorage.getItem('tel'),
        password: this.password
      })
      if (res) {
        localStorage.removeItem('tel')
        // this.$router.go(-3)
        this.$router.push({ path: '/login' })
      }
    }
  }
}
</script>

<style lang="stylus">
</style>
